package com.valveinspectionsys.repair.activity;

import com.valveinspectionsys.R;
import com.valveinspectionsys.dbhelp.XmlNameHelper;
import com.valveinspectionsys.povo.SpinnerVo;
import com.valveinspectionsys.repair.db.RepairDao;
import com.valveinspectionsys.routing.db.DeviceRoutingDao;
import com.valveinspectionsys.util.SharedPreferenceUtil;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.AdapterView.OnItemSelectedListener;

/**
 * 维修设备查询条件
 * @author King
 *  2013-4-27
 */
public class RepairConditionActivity extends Activity{
    
   public EditText  edit1;//设备编号
   
   public Spinner  edit2;//设备名称
   
   public EditText  edit3;//设备地址
   
   public Button  button;//查询
   
   public Spinner  spinner;//设备使用状态
   
    private  String  devicestatus="请选择";
      
   
    private String deviceType="请选择";
    
    private String deviceListid;//设备册ID
    
    public Spinner spinner1;//设备册
    
    public RepairDao  dao;
    public SharedPreferenceUtil sp;
    
    
   
   
   @Override
   protected void onCreate(Bundle savedInstanceState) {
	
	super.onCreate(savedInstanceState);
	setContentView(R.layout.device_query_condition);
	sp=new SharedPreferenceUtil(this);
	dao=new RepairDao(this, sp.getValue(XmlNameHelper.SqliteName));
	TextView t1=(TextView)findViewById(R.id.device_query_condition_textView4);
	t1.setText("维修状态");
	TextView t2=(TextView)findViewById(R.id.device_query_condition_textView5);
	t2.setText("维 修  册");
	edit1=(EditText)findViewById(R.id.device_query_condition_number);
	edit2=(Spinner)findViewById(R.id.device_query_condition_devicename);
	edit3=(EditText)findViewById(R.id.device_query_condition_deviceadds);
	spinner=(Spinner)findViewById(R.id.device_query_condition_devicestatus);
	button=(Button)findViewById(R.id.device_query_condition_query);
	spinner1=(Spinner)findViewById(R.id.device_query_condition_devicelistid);
	String[] date=new String[]{"请选择","未维修","已维修"};
	ArrayAdapter<String> ada1 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, date);// 放数据
	ada1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);// 设置打开方式
	spinner.setAdapter(ada1);
	spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

	    @Override
	    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
		devicestatus=parent.getItemAtPosition(position).toString();
		
	    }

	    @Override
	    public void onNothingSelected(AdapterView<?> parent) {
		
		
	    }
	});
	edit2.setOnItemSelectedListener(new OnItemSelectedListener() {

	    @Override
	    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
		deviceType=parent.getItemAtPosition(position).toString();
		System.out.println("-------------"+deviceType);
		
	    }

	    @Override
	    public void onNothingSelected(AdapterView<?> parent) {
		// TODO Auto-generated method stub
		
	    }
	});
	ArrayAdapter<SpinnerVo> ada2 = new ArrayAdapter<SpinnerVo>(this, android.R.layout.simple_spinner_item, dao.queryAllDeviceList());// 放数据
	ada2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);// 设置打开方式
	spinner1.setAdapter(ada2);
	spinner1.setOnItemSelectedListener(new OnItemSelectedListener() {

	    @Override
	    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
		
		
	    }

	    @Override
	    public void onNothingSelected(AdapterView<?> parent) {
		// TODO Auto-generated method stub
		
	    }
	});
	
   }

   @Override
   protected void onDestroy() {
	dao.close();
	super.onDestroy();
   }

   public String getDevicestatus() {
       return devicestatus;
   }

   public void setDevicestatus(String devicestatus) {
       this.devicestatus = devicestatus;
   }

public String getDeviceType() {
    return deviceType;
}

public void setDeviceType(String deviceType) {
    this.deviceType = deviceType;
}

public String getDeviceListid() {
    return deviceListid;
}

public void setDeviceListid(String deviceListid) {
    this.deviceListid = deviceListid;
}
   
   
   
   
}
